﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CollegeReviewApp.DataModels
{
    public class College
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Address { get; set; }
        public string Phone { get; set; }
        public string Image { get; set; }
        public string URL { get; set; }
        public int Tuition { get; set; }
        public string Description { get; set; }
        public double AcceptanceRate { get; set; }
        public int Enrollment { get; set; }
        public int AverageRating { get; set; }
        public List<Review> ReviewList { get; set; }
        public int getAvgRating()
        {
            int total = 0;
            foreach(var rating in ReviewList){
                total += rating.Rating;
            }
            if (total == 0)
            {
                this.AverageRating = 0;
                return this.AverageRating;
            }
            else
            {
                this.AverageRating = (total / ReviewList.Count());
                return (this.AverageRating);
            }
        }
        public void setProps(College college)
        {
            this.Name = college.Name;
            this.Address = college.Address;
            this.Phone = college.Phone;
            this.Image = college.Image;
            this.Tuition = college.Tuition;
            this.URL = college.URL;
            this.Description = college.Description;
            this.AcceptanceRate = college.AcceptanceRate;
            this.Enrollment = college.Enrollment;
            this.ReviewList = college.ReviewList;
        }
    }
}
